#!/usr/bin/env node

import { simpleCodeParser } from './dist/processors/simple-parser.js';
import fs from 'fs';

// Test a few files to see what's happening
const testFiles = [
    './src/index.ts',
    './package.json', 
    './tsconfig.json',
    './README.md',
    './cli.js'
];

for (const filePath of testFiles) {
    try {
        console.log(`\n=== Testing ${filePath} ===`);
        
        // Check if file exists
        if (!fs.existsSync(filePath)) {
            console.log('File does not exist');
            continue;
        }
        
        // Get file stats
        const stats = fs.statSync(filePath);
        console.log(`File size: ${stats.size} bytes`);
        
        // Parse the file
        const blocks = await simpleCodeParser.parseFile(filePath);
        console.log(`Blocks found: ${blocks.length}`);
        
        if (blocks.length === 0) {
            // Try to understand why no blocks
            const content = fs.readFileSync(filePath, 'utf-8');
            console.log(`Content length: ${content.length} characters`);
            console.log(`Content preview: ${content.slice(0, 100)}...`);
        } else {
            blocks.forEach((block, i) => {
                console.log(`  Block ${i + 1}: ${block.type}, lines ${block.start_line}-${block.end_line}, ${block.content.length} chars`);
            });
        }
    } catch (error) {
        console.error(`Error processing ${filePath}:`, error.message);
    }
}